onCommand

open fun onCommand(name: String, value: String)

Invoked when a command is received by a component this listener is registered with.

Implementers should typically use a switch statement or if-else-if chain on the name} parameter to identify the command and then process it accordingly, using the arg} parameter if provided.

The specific set of command names and the expected format or meaning of their arguments are defined by the system or component issuing the commands. Refer to the relevant documentation for available commands and their usage.

Example command handling:

*public void onCommand(String name, String arg) {
    if ("RESTART_PLAYER".equalsIgnoreCase(name)) {
        // Code to restart the player
    } else if ("SET_VOLUME".equalsIgnoreCase(name)) {
        try {
            int volumeLevel = Integer.parseInt(arg);
            // Code to set player volume
        } catch (NumberFormatException e) {
            // Log error: invalid volume argument
        }
    } else if ("NAVIGATE_TO".equalsIgnoreCase(name)) {
        // Code to navigate to a screen or URL specified in 'arg'
    } else {
        // Log: unhandled command
    }
}
Called when a command is received. This method executes a Javascript function `RevelDigital.Controller.onCommand` within the loaded web page if the `RevelDigital` object exists. It also triggers a Javascript event "RevelDigital.Command" with the command name and value as details.

Parameters

name

The name of the command.

value

The value associated with the command.

See also